import React, { Component } from 'react'
//导入store
import store from '../../store'
//导入action
import { sendAction } from '../../action'
export default class Home extends Component {
  handleClick = () => {
    const action = sendAction()
    //发送一个action 利用store
    store.dispatch(action)
  }
  //当组件加载完毕进行监听
  componentDidMount() {
    store.subscribe(() => {
      console.log('sub', store.getState())
      this.setState({})
    })
  }
  render() {
    return (
      <div>
        <button onClick={this.handleClick}>点我</button>
        <h3>{store.getState().value}</h3>
      </div>
    )
  }
}
